package fhp.hlhj.giantfold.activity.malls

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.kepler.jd.login.KeplerApiManager
import com.kepler.jd.sdk.bean.KeplerAttachParameter
import fhp.hlhj.giantfold.BaseActivity
import fhp.hlhj.giantfold.R
import com.kepler.jd.Listener.OpenAppAction
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.HttpParams
import com.lzy.okgo.model.Response
import fhp.hlhj.giantfold.interfaces.IJdList
import fhp.hlhj.giantfold.javaBean.JDBean
import fhp.hlhj.giantfold.network.Urls
import fhp.hlhj.giantfold.presenter.JdListPrensenter
import fhp.hlhj.giantfold.utils.JDSignUtil
import fhp.hlhj.giantfold.utils.LogUtil
import fhp.hlhj.giantfold.utils.MyUtils
import kotlinx.android.synthetic.main.activity_search_good_aty.*
import java.io.File


class JdOrderListAty : BaseActivity(), IJdList {
    private lateinit var jdlistPresenter:JdListPrensenter
    override fun getContentId(): Int = R.layout.activity_jd_order_list_aty

    override fun initView() {
        jdlistPresenter= JdListPrensenter(this)

        val params = HttpParams()
        val yewuStr="{\"beginTime\":\"20180304010101\",\"endTime\":\"20180309235959\",\"pageIndex\":1,\"pageSize\":10}"
        val timeStamp = MyUtils.timeStampToStr(System.currentTimeMillis())
        params.put("v","2.0")
        params.put("method","jd.kepler.order.getlist")
        LogUtil.logi(timeStamp)
        params.put("timestamp", timeStamp)
        params.put("sign_method","md5")
        params.put("format","json")
        params.put("app_key","29cbb099a1924034a6aee10997296e74")
        params.put("param_json",yewuStr)
        params.put("sign",JDSignUtil.buildSign(timeStamp,"2.0","md5","json","jd.kepler.order.getlist"
                ,yewuStr,null,"29cbb099a1924034a6aee10997296e74","1d4d051201864e5c86e6519e01b0c4f3"))
/*        params.put("pageSize",10)
        params.put("pageIndex",1)
        params.put("beginTime","20170101000000")
        params.put("endTime","20180101000000")*/

        jdlistPresenter.getJdList(params)
        val parameter = KeplerAttachParameter()
        parameter.setCustomerInfo("hlhjjz")
        KeplerApiManager.getWebViewService().openNavigationWebViewPage(parameter)
    }

    override fun getJdOrderList(resp: Response<String>) {
        LogUtil.logi(resp.body().toString())
/*        if (jdBean.jd_kepler_order_getList_response==null){
            MyUtils.toast("空")
            val orders = jdBean.jd_kepler_order_getList_response.orders
        }*/

    }
}
